package com.pb.infra.oth.util;

import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.pb.infra.oth.entity.excel.Excel;
import com.pb.infra.oth.entity.excel.ExcelSheet;
import com.pb.infra.oth.entity.excel.MergeCell;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.*;
import org.apache.poi.xssf.usermodel.*;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.util.*;
import java.util.regex.Pattern;

/**
 * 通用导出excel
 *
 * @author liudebao
 * @date 2020/1/9
 */
public class ExportExcelUtil {
    private ExportExcelUtil() {
        throw new IllegalStateException("Utility class");
    }

    /**
     * 导出excel2003
     *暂不用
     * @param excel
     * @param excelSheet
     * @param response
     */
    /*public static void exportExcel2003(Excel excel, ExcelSheet[] excelSheet, HttpServletResponse response) throws Exception {
        excel.setSuffix(".xls");
        if (excelSheet.length == 1 && StringUtil.isEmpty(excelSheet[0].getSheetName())) {
            excelSheet[0].setSheetName(excel.getFileName());
        }
        exportExcel(new HSSFWorkbook(), excel, excelSheet, response);
    }*/

    /**
     * 导出excel2003
     * 暂不用
     * @param excel
     * @param excelSheet
     */
    /*public static HSSFWorkbook exportExcel2003(Excel excel, ExcelSheet[] excelSheet) throws Exception {
        HSSFWorkbook workbook = new HSSFWorkbook();
        excel.setSuffix(".xls");
        if (excelSheet.length == 1 && StringUtil.isEmpty(excelSheet[0].getSheetName())) {
            excelSheet[0].setSheetName(excel.getFileName());
        }
        exportExcel(workbook, excel, excelSheet, null);
        return workbook;
    }*/

    /**
     * 导出excel2007
     *
     * @param excel
     * @param excelSheet
     * @param response
     */
    public static void exportExcel2007(Excel excel, ExcelSheet[] excelSheet, HttpServletResponse response) throws Exception {
        excel.setSuffix(".xlsx");
        if (excelSheet.length == 1 && StringUtil.isEmpty(excelSheet[0].getSheetName())) {
            excelSheet[0].setSheetName(excel.getFileName());
        }
        exportExcel(new SXSSFWorkbook(), excel, excelSheet, response);
    }

    /**
     * 导出excel2007
     *暂不用
     * @param excel
     * @param excelSheet
     */
    /*public static XSSFWorkbook exportExcel2007(Excel excel, ExcelSheet[] excelSheet) throws Exception {
        XSSFWorkbook workbook = new XSSFWorkbook();
        excel.setSuffix(".xlsx");
        if (excelSheet.length == 1 && StringUtil.isEmpty(excelSheet[0].getSheetName())) {
            excelSheet[0].setSheetName(excel.getFileName());
        }
        exportExcel(workbook, excel, excelSheet, null);
        return workbook;
    }*/

    /**
     * 导出excel
     *
     * @param workbook
     * @param excel
     * @param excelSheet
     * @param response
     */
    public static void exportExcel(Workbook workbook, Excel excel, ExcelSheet[] excelSheet, HttpServletResponse response) throws Exception {
        for (ExcelSheet sheet : excelSheet) {
            createSheet(workbook, sheet, excel.getSuffix());
        }
        if (response != null) {
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(excel.getFileName() + excel.getSuffix(), "utf-8"));
            OutputStream os = response.getOutputStream();
            workbook.write(os);
            os.flush();
            os.close();
        }
    }

    /**
     * 创建sheet
     *
     * @param workbook
     * @param excelSheet
     * @param suffix
     */
    public static void createSheet(Workbook workbook, ExcelSheet excelSheet, String suffix) throws Exception {
        SXSSFSheet sheet = (SXSSFSheet)workbook.createSheet(excelSheet.getSheetName());
        //设置密码保护工作表
        if (!StringUtil.isEmpty(excelSheet.getPasswd())) {
            sheet.protectSheet(excelSheet.getPasswd());
        }
        //冻结单元格
        if (excelSheet.getFixedCell() != null) {
            sheet.createFreezePane(excelSheet.getFixedCell().getColIndex(), excelSheet.getFixedCell().getRowIndex());
        }
        int rowIndex = 0;
        //创建标题
        if (!StringUtil.isEmpty(excelSheet.getTitle())) {
            createTitle(workbook, sheet, excelSheet, rowIndex);
            rowIndex++;
        }
        //创建表头
        if (!StringUtil.isEmpty(excelSheet.getSubTitle())) {
            createSubTitle(workbook, sheet, excelSheet, rowIndex);
            rowIndex++;
        }
        //创建列头
        if (excelSheet.getHeader() != null && excelSheet.getHeader().length > 0 && excelSheet.getHeader()[0].length > 0) {
            createHeader(workbook, sheet, excelSheet, rowIndex, suffix);
            rowIndex += excelSheet.getHeader().length;
            //创建批注
            if (excelSheet.getComment() != null && excelSheet.getComment().length > 0) {
                createComment(sheet, excelSheet, rowIndex - 1, suffix);
            }
        }
        //创建数据
        if (excelSheet.getColumn() != null && excelSheet.getColumn().length > 0 && excelSheet.getData() != null && excelSheet.getData().size() > 0) {
            createData(workbook, sheet, excelSheet, rowIndex);
        }
        //合并单元格
        if (excelSheet.getMergeCell() != null && excelSheet.getMergeCell().length > 0) {
            for (MergeCell mergeCell : excelSheet.getMergeCell()) {
                sheet.addMergedRegion(new CellRangeAddress(mergeCell.getStartRowIndex(), mergeCell.getEndRowIndex(), mergeCell.getStartColIndex(), mergeCell.getEndColIndex()));
            }
        }
    }

    /**
     * 创建标题
     *
     * @param workbook
     * @param sheet
     * @param excelSheet
     * @param rowIndex
     */
    public static void createTitle(Workbook workbook, Sheet sheet, ExcelSheet excelSheet, int rowIndex) {
        Row row = sheet.createRow(rowIndex);
        Cell cell = row.createCell(0);
        cell.setCellValue(excelSheet.getTitle());
        Font font = workbook.createFont();
        font.setBold(true);
        font.setFontName(Constant.EXCEL_FONT);
        font.setFontHeightInPoints(Constant.EXCEL_TITLE_FONT_SIZE);
        CellStyle style = workbook.createCellStyle();
        style.setFont(font);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        style.setAlignment(HorizontalAlignment.CENTER);
        cell.setCellStyle(style);
        if (excelSheet.getHeader() != null && excelSheet.getHeader().length > 0 && excelSheet.getHeader()[0].length > 0) {
            sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, excelSheet.getHeader()[0].length - 1));
        }
    }

    /**
     * 创建表头
     *
     * @param workbook
     * @param sheet
     * @param excelSheet
     * @param rowIndex
     */
    public static void createSubTitle(Workbook workbook, Sheet sheet, ExcelSheet excelSheet, int rowIndex) {
        Row row = sheet.createRow(rowIndex);
        Cell cell = row.createCell(0);
        cell.setCellValue(excelSheet.getSubTitle());
        Font font = workbook.createFont();
        font.setBold(true);
        font.setFontName(Constant.EXCEL_FONT);
        font.setFontHeightInPoints(Constant.EXCEL_DATA_FONT_SIZE);
        CellStyle style = workbook.createCellStyle();
        style.setFont(font);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        style.setAlignment(HorizontalAlignment.LEFT);
        cell.setCellStyle(style);
        if (excelSheet.getHeader() != null && excelSheet.getHeader().length > 0 && excelSheet.getHeader()[0].length > 0) {
            sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, excelSheet.getHeader()[0].length - 1));
        }
    }

    /**
     * 创建列头
     *
     * @param workbook
     * @param sheet
     * @param excelSheet
     * @param rowIndex
     * @param suffix
     */
    public static void createHeader(Workbook workbook, SXSSFSheet sheet, ExcelSheet excelSheet, int rowIndex, String suffix) {
        SXSSFRow row;
        SXSSFCell cell;
        Font font = workbook.createFont();
        font.setBold(true);
        font.setFontName(Constant.EXCEL_FONT);
        font.setFontHeightInPoints(Constant.EXCEL_DATA_FONT_SIZE);
        font.setColor(IndexedColors.WHITE.getIndex());
        CellStyle cellStyle = null;
        if (".xls".equals(suffix)) {
            HSSFCellStyle style = (HSSFCellStyle) workbook.createCellStyle();
            style.setFont(font);
            style.setVerticalAlignment(VerticalAlignment.CENTER);
            style.setAlignment(HorizontalAlignment.CENTER);
            style.setFillForegroundColor(((HSSFWorkbook) workbook).getCustomPalette().findSimilarColor(Constant.EXCEL_HEAD_COLOR_R, Constant.EXCEL_HEAD_COLOR_G, Constant.EXCEL_HEAD_COLOR_B).getIndex());
            style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
            cellStyle = style;
        } else if (".xlsx".equals(suffix)) {
            CellStyle style = workbook.createCellStyle();
            style.setFont(font);
            style.setVerticalAlignment(VerticalAlignment.CENTER);
            style.setAlignment(HorizontalAlignment.CENTER);
            style.setFillForegroundColor((new HSSFWorkbook()).getCustomPalette().findSimilarColor(Constant.EXCEL_HEAD_COLOR_R, Constant.EXCEL_HEAD_COLOR_G, Constant.EXCEL_HEAD_COLOR_B).getIndex());
            style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
            cellStyle = style;
            /*XSSFCellStyle style = (XSSFCellStyle) workbook.createCellStyle();
            style.setFont(font);
            style.setVerticalAlignment(VerticalAlignment.CENTER);
            style.setAlignment(HorizontalAlignment.CENTER);
            style.setFillForegroundColor(new XSSFColor(new java.awt.Color(Constant.EXCEL_HEAD_COLOR_R, Constant.EXCEL_HEAD_COLOR_G, Constant.EXCEL_HEAD_COLOR_B)));
            style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
            cellStyle = style;*/
        }
        for (int i = 0; i < excelSheet.getHeader().length; i++) {
            row = sheet.createRow(rowIndex + i);
            for (int j = 0; j < excelSheet.getHeader()[i].length; j++) {
                cell = row.createCell(j);
                cell.setCellValue(excelSheet.getHeader()[i][j]);
                cell.setCellStyle(cellStyle);
                cell.setCellType(CellType.STRING);
                setColumnWidth(sheet, cell);
            }
            break;
        }
    }

    /**
     * 创建批注
     *
     * @param sheet
     * @param excelSheet
     * @param rowIndex
     * @param suffix
     */
    public static void createComment(SXSSFSheet sheet, ExcelSheet excelSheet, int rowIndex, String suffix) {
        for (int i = 0; i < excelSheet.getComment().length; i++) {
            String[] comments = excelSheet.getComment();
            if (!StringUtil.isEmpty(excelSheet.getComment()[i])) {
                //Comment comment = null;
                if (".xls".equals(suffix)) {
                    /*HSSFPatriarch patriarch = (HSSFPatriarch) sheet.createDrawingPatriarch();
                    comment = patriarch.createCellComment(new HSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
                    comment.setString(new HSSFRichTextString(excelSheet.getComment()[i]));*/
                } else if (".xlsx".equals(suffix)) {
                    SXSSFCell cell = sheet.getRow(0).getCell(i);
                    if (comments != null) {
                        if (!"".equals(comments[i]) && comments[i] != null) {
                            ClientAnchor anchor = new XSSFClientAnchor();
                            anchor.setDx1(0);
                            anchor.setDx2(0);
                            anchor.setDy1(0);
                            anchor.setDy2(0);
                            anchor.setCol1(cell.getColumnIndex());
                            anchor.setRow1(cell.getRowIndex());
                            anchor.setCol2(cell.getColumnIndex() + 3);
                            anchor.setRow2(cell.getRowIndex() + 4);
                            SXSSFDrawing drawing = sheet.createDrawingPatriarch();
                            Comment comment = drawing.createCellComment(anchor);
                            comment.setString(new XSSFRichTextString(comments[i]));
                            if (sheet != null && sheet.getRow(0) != null && sheet.getRow(0).getCell(i) != null && comment != null) {
                                sheet.getRow(0).getCell(i).setCellComment(comment);
                            }
                        }
                    }
                    /*XSSFDrawing drawing = (XSSFDrawing) sheet.createDrawingPatriarch();
                    comment = drawing.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
                    comment.setString(new XSSFRichTextString(excelSheet.getComment()[i]));*/
                }
                /*if (sheet != null && sheet.getRow(rowIndex) != null && sheet.getRow(rowIndex).getCell(i) != null && comment != null) {
                    sheet.getRow(rowIndex).getCell(i).setCellComment(comment);
                }*/
            }
        }
    }

    /**
     * 创建内容
     *
     * @param workbook
     * @param sheet
     * @param excelSheet
     * @param rowIndex
     */
    public static void createData(Workbook workbook, SXSSFSheet sheet, ExcelSheet excelSheet, int rowIndex) throws Exception {
        Row row;
        Cell cell;
        Font font = workbook.createFont();
        font.setFontName(Constant.EXCEL_FONT);
        font.setFontHeightInPoints(Constant.EXCEL_DATA_FONT_SIZE);
        CellStyle style;
        for (int i = 0; i < excelSheet.getData().size(); i++) {
            if (i % 1000 == 0) {
                sheet.flushRows();
            }
            row = sheet.createRow(rowIndex);
            for (int j = 0; j < excelSheet.getColumn().length; j++) {
                cell = row.createCell(j);
                style = workbook.createCellStyle();
                style.setFont(font);
                style.setVerticalAlignment(VerticalAlignment.CENTER);
                String type;
                Object value;
                if (excelSheet.getData().get(i) instanceof Map || excelSheet.getData().get(i) instanceof HashMap) {
                    Map<String, Object> map = (Map<String, Object>) excelSheet.getData().get(i);
                    value = map.get(excelSheet.getColumn()[j].getName());
                    type = value == null ? "" : value.getClass().getTypeName();
                } else {
                    Class<? extends Object> cls = excelSheet.getData().get(i).getClass();
                    String name = excelSheet.getColumn()[j].getName();
                    type = getField(cls, name).getGenericType().getTypeName();
                    name = name.replaceFirst(name.substring(0, 1), name.substring(0, 1).toUpperCase(Locale.ENGLISH));
                    Method method = cls.getMethod("get" + name);
                    value = method.invoke(excelSheet.getData().get(i));
                }
                if (!StringUtil.isEmpty(type) && !StringUtil.isEmpty(value)) {
                    Pattern pattern = Pattern.compile("^\\-?\\d+(\\.\\d+)?$");
                    switch (type) {
                        case "java.lang.String":
                            if (value.toString().charAt(0) == '=' && pattern.matcher(value.toString().substring(1)).matches()) {
                                cell.setCellFormula(value.toString().substring(1));
                                style.setAlignment(excelSheet.getColumn()[j].getAlign() == null ? HorizontalAlignment.RIGHT : excelSheet.getColumn()[j].getAlign());
                                style.setDataFormat(workbook.createDataFormat().getFormat(Constant.EXCEL_NUMBER_FORMAT));
                            } else {
                                //cell.setCellType(CellType.STRING);
                                cell.setCellValue(value.toString());
                                style.setAlignment(excelSheet.getColumn()[j].getAlign() == null ? HorizontalAlignment.LEFT : excelSheet.getColumn()[j].getAlign());
                            }
                            break;
                        case "java.lang.Double":
                        case "java.lang.Float":
                            //cell.setCellType(CellType.NUMERIC);
                            cell.setCellValue((Double) value);
                            style.setAlignment(excelSheet.getColumn()[j].getAlign() == null ? HorizontalAlignment.RIGHT : excelSheet.getColumn()[j].getAlign());
                            style.setDataFormat(workbook.createDataFormat().getFormat(Constant.EXCEL_NUMBER_FORMAT));
                            break;
                        case "java.math.BigDecimal":
                            //cell.setCellType(CellType.NUMERIC);
                            cell.setCellValue(Double.parseDouble(value.toString()));
                            style.setAlignment(excelSheet.getColumn()[j].getAlign() == null ? HorizontalAlignment.RIGHT : excelSheet.getColumn()[j].getAlign());
                            style.setDataFormat(workbook.createDataFormat().getFormat(Constant.EXCEL_NUMBER_FORMAT));
                            break;
                        case "java.lang.Integer":
                            //cell.setCellType(CellType.NUMERIC);
                            cell.setCellValue((Integer) value);
                            style.setAlignment(excelSheet.getColumn()[j].getAlign() == null ? HorizontalAlignment.RIGHT : excelSheet.getColumn()[j].getAlign());
                            break;
                        default:
                            //cell.setCellType(CellType.STRING);
                            cell.setCellValue(value.toString());
                            style.setAlignment(excelSheet.getColumn()[j].getAlign() == null ? HorizontalAlignment.LEFT : excelSheet.getColumn()[j].getAlign());
                            break;
                    }
                }
                cell.setCellStyle(style);
                //setColumnWidth(sheet, cell);
            }
            rowIndex++;
        }
    }

    /**
     * 设置自适应列宽
     *
     * @param sheet
     * @param cell
     */
    public static void setColumnWidth(SXSSFSheet sheet, Cell cell) {
        sheet.trackAllColumnsForAutoSizing();
        sheet.autoSizeColumn(cell.getColumnIndex());
        int colWidth = sheet.getColumnWidth(cell.getColumnIndex()) / 256;
        int width = cell.toString().getBytes().length;
        if (width > colWidth) {
            if (width > 255) {
                sheet.setColumnWidth(cell.getColumnIndex(), 254 * 256);
            } else {
                sheet.setColumnWidth(cell.getColumnIndex(), width * 256);
            }
        }
    }

    /**
     * 获取对象的属性
     *
     * @param cls
     * @param name
     * @return
     */
    public static Field getField(Class cls, String name) {
        try {
            return cls.getDeclaredField(name);
        } catch (NoSuchFieldException e) {
            try {
                return cls.getSuperclass().getDeclaredField(name);
            } catch (NoSuchFieldException e1) {
                try {
                    return cls.getSuperclass().getSuperclass().getDeclaredField(name);
                } catch (NoSuchFieldException e2) {
                    return null;
                }
            }
        }
    }

    /**
     * 生成文件
     * @param workbook
     * @param fileName
     */
    public static void workbookConvertorStream(Workbook workbook, String fileName,String path) {


        try {
            File files = new File(path);
            if (!files.exists()) {
                files.mkdirs();
            }
            //创建临时文件
            FileOutputStream file = new FileOutputStream(fileName);
            workbook.write(file);
            workbook.close();
            file.flush();
            file.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 表格头样式
     *
     * @return WriteCellStyle
     */
    public static WriteCellStyle headerStyle() {
        WriteCellStyle headWriteCellStyle = new WriteCellStyle();

        headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);

        headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
        // 设置头部背景为蓝色
        headWriteCellStyle.setFillForegroundColor(IndexedColors.BLUE.getIndex());
        headWriteCellStyle.setBorderTop(BorderStyle.THIN);
        headWriteCellStyle.setBorderBottom(BorderStyle.THIN);
        headWriteCellStyle.setBorderLeft(BorderStyle.THIN);
        headWriteCellStyle.setBorderRight(BorderStyle.THIN);
        headWriteCellStyle.setBottomBorderColor(IndexedColors.WHITE.getIndex());
        headWriteCellStyle.setTopBorderColor(IndexedColors.WHITE.getIndex());
        headWriteCellStyle.setLeftBorderColor(IndexedColors.WHITE.getIndex());
        headWriteCellStyle.setRightBorderColor(IndexedColors.WHITE.getIndex());


        WriteFont headWriteFont = new WriteFont();
        headWriteFont.setFontHeightInPoints(Constant.EXCEL_DATA_FONT_SIZE);
        headWriteFont.setColor(IndexedColors.WHITE.getIndex());
        headWriteFont.setBold(true);
        headWriteFont.setFontName(Constant.EXCEL_FONT);

        headWriteCellStyle.setWriteFont(headWriteFont);
        return headWriteCellStyle;
    }

    /**
     * 数据样式
     *
     * @return WriteCellStyle
     */
    public static WriteCellStyle mainStyle() {
        // 内容的策略
        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();

//        HorizontalCellStyleStrategy strategy=new HorizontalCellStyleStrategy();
        //左右对其方式
        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        //上下对其方式
        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);

        //边框
        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
        contentWriteCellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
        contentWriteCellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
        contentWriteCellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
        contentWriteCellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());

        // 这里需要指定 FillPatternType 为FillPatternType.SOLID_FOREGROUND 不然无法显示背景颜色.头默认了 FillPatternType所以可以不指定
        //contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);

        WriteFont contentWriteFont = new WriteFont();
        // 字体大小
        contentWriteFont.setFontHeightInPoints(Constant.EXCEL_DATA_FONT_SIZE);
        contentWriteCellStyle.setWriteFont(contentWriteFont);
        return contentWriteCellStyle;
    }

    /**
     * 导出
     *暂不用
     * @param excel
     * @param response
     * @throws Exception
     */
    /*public static void easyExport(EasyExcelEntity excel, HttpServletResponse response) throws Exception {
        ExcelTypeEnum excelType;
        if (excel.getFileName().toLowerCase().endsWith(".xls")) {
            excelType = ExcelTypeEnum.XLS;
        } else if (excel.getFileName().toLowerCase().endsWith(".xlsx")) {
            excelType = ExcelTypeEnum.XLSX;
        } else {
            excel.setFileName(excel.getFileName().concat(".xlsx"));
            excelType = ExcelTypeEnum.XLSX;
        }
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(excel.getFileName(), "utf-8"));
        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).excelType(excelType).build();
        WriteSheet writeSheet;
        List<List<String>> heads;
        for (EasySheetEntity sheet : excel.getSheet()) {
            heads = new ArrayList<>();
            for (String[] head : sheet.getHead()) {
                heads.add(Arrays.asList(head));
            }
            writeSheet = EasyExcel.writerSheet(excel.getSheet().indexOf(sheet), sheet.getSheetName()).registerWriteHandler(new HorizontalCellStyleStrategy(headStyle(), dataStyle())).build();
            writeSheet.setHead(heads);
            writeSheet.setIncludeColumnFiledNames(Arrays.asList(sheet.getColumn()));
            excelWriter.write(sheet.getData(), writeSheet);
        }
        excelWriter.finish();
    }*/

    /**
     * 标题样式
     *暂不用
     * @return
     */
    /*public static WriteCellStyle headStyle() {
        WriteFont font = new WriteFont();
        font.setBold(true);
        font.setFontName(Constant.EXCEL_FONT);
        font.setFontHeightInPoints(Constant.EXCEL_DATA_FONT_SIZE);
        font.setColor(IndexedColors.WHITE.getIndex());
        WriteCellStyle style = new WriteCellStyle();
        style.setWrapped(false);
        style.setWriteFont(font);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        style.setHorizontalAlignment(HorizontalAlignment.CENTER);
        style.setFillForegroundColor(IndexedColors.LIGHT_BLUE.getIndex());
        return style;
    }*/

    /**
     * 内容样式
     *暂不用
     * @return
     */
    /*public static WriteCellStyle dataStyle() {
        WriteFont font = new WriteFont();
        font.setFontName(Constant.EXCEL_FONT);
        font.setFontHeightInPoints(Constant.EXCEL_DATA_FONT_SIZE);
        WriteCellStyle style = new WriteCellStyle();
        style.setWrapped(false);
        style.setWriteFont(font);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        return style;
    }*/
}
